package com.tcp2.frame.plat;

import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Author: <张锦煌>
 * Time: 2015-09-23 11:17
 * Copyright (C) 2015 Xiamen Yaxon Networks CO.,LTD.
 * 下班签退信息窗体
 */
public class Frame0B04 {

    private JPanel jPanel;
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date time=new Date();
    public JTextField licenseField = new JTextField("1010101010");
    public JTextField driverNoField = new JTextField("101010101010");
    public JTextField meterField=new JTextField("1111");
    public JTextField powerDateField=new JTextField(format.format(new Date(time.getTime()-8*60*1000)));
    public JTextField shutdownDateField=new JTextField(format.format(time));
    public JTextField mileField=new JTextField("30.2");
    public JTextField opeMileField=new JTextField("20.2");
    public JTextField numberField=new JTextField("3");
    public JTextField timingField=new JTextField("00:10:00");
    public JTextField totalMoneyField=new JTextField("30.3");
    public JTextField cardMoneyField=new JTextField("20.3");
    public JTextField cardNumberField=new JTextField("10");
    public JTextField intervalMileField=new JTextField("5.3");
    public JTextField totalMileField=new JTextField("5000.3");
    public JTextField totalOpeMileField=new JTextField("4000.3");
    public JTextField priceField=new JTextField("0.2");
    public JTextField totalOpeNumberField=new JTextField("30");
    private String[] s={"0:正常签退","1:强制签退"};
    private ComboBoxModel mode=new AModel(s);
    public JComboBox typeCom=new JComboBox(mode);
    public JTextArea exaArea=new JTextArea();
    //扩展属性
    public JRadioButton rb1=new JRadioButton("有",true);
    public JRadioButton rb2=new JRadioButton("无");

    //签到数据类型
    public JTextField dataTypeField = new JTextField("0");

    //扩展数据内容
    public JTextArea extraDataArea=new JTextArea();

    public Frame0B04(JPanel jPanel){
        this.jPanel=jPanel;
    }

    public void init(){
        JLabel l1=new JLabel("运营许可证号: ");
        JLabel l2=new JLabel("驾驶证号:     ");
        JLabel l3=new JLabel("计价器K值:    ");
        JLabel l4=new JLabel("当班开机时间: ");
        JLabel l5=new JLabel("当班关机时间: ");
        JLabel l6=new JLabel("当班里程:     ");
        JLabel l7=new JLabel("当班营运里程: ");
        JLabel l8=new JLabel("车次:         ");
        JLabel l9=new JLabel("计时时间:     ");
        JLabel l10=new JLabel("总计金额:     ");
        JLabel l11=new JLabel("卡收金额:     ");
        JLabel l12=new JLabel("卡次:         ");
        JLabel l13=new JLabel("班间里程:     ");
        JLabel l14=new JLabel("总里程:       ");
        JLabel l15=new JLabel("总运营里程:   ");
        JLabel l16=new JLabel("单价:         ");
        JLabel l17=new JLabel("总营运次数:   ");
        JLabel l18 = new JLabel("是否有扩展属性: ");
        ButtonGroup bg1=new ButtonGroup();
        bg1.add(rb1);
        bg1.add(rb2);
        Box box7 = Box.createHorizontalBox();
        box7.add(l18);
        box7.add(rb1);box7.add(rb2);

        JLabel l19 = new JLabel("签到数据类型:   ");
        Box box5 = Box.createHorizontalBox();
        box5.add(l19);
        box5.add(Box.createHorizontalStrut(47));
        box5.add(dataTypeField);

        JLabel l20 = new JLabel("扩展数据内容:   ");
        JScrollPane js=new JScrollPane(extraDataArea);
        Box box4 = Box.createHorizontalBox();
        box4.add(l20);
        box4.add(Box.createHorizontalStrut(47));
        box4.add(js);

        Box box1 = Box.createHorizontalBox();
        JLabel jlDesc = new JLabel("功能描述:下班签退信息上传,基本位置信息自动生成。消息ID=0x0B04");
        box1.add(jlDesc);
        JPanel jp1 = new JPanel();
        TitledBorder t1 = new TitledBorder("下班签退信息上传");
        jp1.setBorder(t1);
        Box b1=Box.createHorizontalBox();
        b1.add(l1);b1.add(licenseField);
        Box b2=Box.createHorizontalBox();
        b2.add(l2);b2.add(driverNoField);
        Box b3=Box.createHorizontalBox();
        b3.add(l3);b3.add(meterField);
        Box b4=Box.createHorizontalBox();
        b4.add(l4);b4.add(powerDateField);
        Box b5=Box.createHorizontalBox();
        b5.add(l5);b5.add(shutdownDateField);
        Box b6=Box.createHorizontalBox();
        b6.add(l6);b6.add(mileField);
        Box b7=Box.createHorizontalBox();
        b7.add(l7);b7.add(opeMileField);
        Box b8=Box.createHorizontalBox();
        b8.add(l8);b8.add(numberField);
        Box b9=Box.createHorizontalBox();
        b9.add(l9);b9.add(timingField);
        Box b10=Box.createHorizontalBox();
        b10.add(l10);b10.add(totalMoneyField);
        Box v1=Box.createVerticalBox();
        v1.add(b1);v1.add(Box.createVerticalStrut(10));
        v1.add(b2);v1.add(Box.createVerticalStrut(10));
        v1.add(b3);v1.add(Box.createVerticalStrut(10));
        v1.add(b4);v1.add(Box.createVerticalStrut(10));
        v1.add(b5);v1.add(Box.createVerticalStrut(10));
        v1.add(b6);v1.add(Box.createVerticalStrut(10));
        v1.add(b7);v1.add(Box.createVerticalStrut(10));
        v1.add(b8);v1.add(Box.createVerticalStrut(10));
        v1.add(b9);v1.add(Box.createVerticalStrut(10));
        v1.add(b10);
        Box h1=Box.createHorizontalBox();
        h1.add(l11);h1.add(cardMoneyField);
        Box h2=Box.createHorizontalBox();
        h2.add(l12);h2.add(cardNumberField);
        Box h3=Box.createHorizontalBox();
        h3.add(l13);h3.add(intervalMileField);
        Box h4=Box.createHorizontalBox();
        h4.add(l14);h4.add(totalMileField);
        Box h5=Box.createHorizontalBox();
        h5.add(l15);h5.add(totalOpeMileField);
        Box h6=Box.createHorizontalBox();
        h6.add(l16);h6.add(priceField);
        Box h7=Box.createHorizontalBox();
        h7.add(l17);h7.add(totalOpeNumberField);
        Box v2=Box.createVerticalBox();
        v2.add(h1);v2.add(Box.createVerticalStrut(10));
        v2.add(h2);v2.add(Box.createVerticalStrut(10));
        v2.add(h3);v2.add(Box.createVerticalStrut(10));
        v2.add(h4);v2.add(Box.createVerticalStrut(10));
        v2.add(h5);v2.add(Box.createVerticalStrut(10));
        v2.add(h6);v2.add(Box.createVerticalStrut(10));
        v2.add(h7);v2.add(Box.createVerticalStrut(10));
        v2.add(box7);v2.add(Box.createVerticalStrut(10));
        v2.add(box5);v2.add(Box.createVerticalStrut(10));
        v2.add(box4);
        Box h=Box.createHorizontalBox();
        h.add(v1);h.add(Box.createHorizontalStrut(40));h.add(v2);
        jp1.add(h);

        Box vBox = Box.createVerticalBox();
        vBox.add(Box.createVerticalStrut(10));
        vBox.add(box1);
        vBox.add(Box.createVerticalStrut(10));
        vBox.add(jp1);

        jPanel.add(vBox,"p8");
    }

    class AModel extends DefaultComboBoxModel{

        AModel(String[] s){

            for(int i=0;i<s.length;i++){
                addElement(s[i]);
            }
        }
    }

}
